<?php
/**
 * Created by PhpStorm.
 * User: divya
 * Date: 2018/7/30
 * Time: 下午5:18
 */

namespace app\api\controller\v1;


use app\lib\exception\CategoryException;
use think\Controller;
use app\api\model\Category as CateoryModel;
class Category extends Controller
{
    public static function getAllCategorys(){
        $catetories = CateoryModel::getCatetory();
        if ($catetories->isEmpty()){
            throw new CategoryException();
        }
        return $catetories;
    }
    public static function getCategoryById($id){
        $catetories = CateoryModel::getCatetoryById($id);
        if (!$catetories){
            throw new CategoryException();
        }
        return $catetories;
    }
}